import Vue from 'vue'
import Vuex from 'vuex'
import mutations from './mutations.js'
import actions from './actions.js'
import getters from './getters.js'
import state from './state.js'
Vue.use(Vuex)
//Vuex

const store = new Vuex.Store({
    state,
    mutations,
    actions,
    getters
    
})
if(module.hot){
    module.hot.accept(['./actions.js','./getters.js','./mutations.js','./state.js'],() => {
        //1.获取更新后的模块
        //因为babel6的模块编译格式问题，这里需要加上.default
        const newMutations=require('./mutations').default
        const newActions=require('./actions').default
        const newGetters=require('./getters').default
        const newState=require('./state').default        
        //const new ModuleA=require('./modules/a').default
        //2.加载新模块
        store.hotUpdate({
            mutations:newMutations,
            actions:newActions,
            getters:newGetters,
            state:newState
        })
    })
}
export default store
